
#ifndef SQLParser_HEADER_H
#define SQLParser_HEADER_H

#include <string>
#include "Lexer.h"
#include "ParserException.h"
#include "Token.h"
#include "SQLParserFeature.h"
#include "../../DbType.h"

class SQLParser
{
private:
  BOOL_ptr lexerHere;

public:
  Lexer_ptr lexer;
  DbType_ptr dbType;

  bool identifierEquals(string_ptr text);
  bool identifierEquals(const char *);
  void acceptIdentifier(string_ptr text);
  void acceptIdentifier(const char *text);

  string_ptr as();
  string_ptr alias();

  void setErrorEndPos(int errPos);

  SQLParser();
  SQLParser(string_ptr sql);
  SQLParser(Lexer_ptr lexer);
  SQLParser(Lexer_ptr lexer, DbType_ptr dbType);
  SQLParser(string_ptr sql, DbType_ptr dbType, SQLParserFeature_list_ptr features);
  ~SQLParser();

  Lexer_ptr getLexer();

  void accept(Token token);

  void match(Token token);
  void config(SQLParserFeature_ptr feature, BOOL_ptr state);
  DbType_ptr getDbType()
  {
    return dbType;
  }
  BOOL_ptr isEnabled(SQLParserFeature_ptr feature) { return lexer->isEnabled(feature); }
  string_ptr tableAlias();
  string_ptr tableAlias(BOOL_ptr must);
  int acceptInteger();
  SHAREDOBJECT(SQLParser);

private:
  int errorEndPos;
  // string_ptr  alias;
};
// typedef boost::shared_ptr<SQLParser> SQLParser_ptr;

#endif
